From 6efef1afab1daf899eb718d9a04e1d4b393ee313 Mon Sep 17 00:00:00 2001 From: "emellor@leeni.uk.xensource.com" Date: Mon, 12 Dec 2005 16:32:19 +0000 Subject: [PATCH] Make from_string('') return []. This means that it is not necessary for our callers to special-case this value -- the [] is a valid sxp. Signed-off-by: Ewan Mellor --- tools/python/xen/xend/sxp.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tools/python/xen/xend/sxp.py b/tools/python/xen/xend/sxp.py index 88a81cdc8a..551a8d3ec2 100644 --- a/tools/python/xen/xend/sxp.py +++ b/tools/python/xen/xend/sxp.py @@ -696,13 +696,16 @@ def to_string(sxpr): io.close() return val -def from_string(str): +def from_string(s): """Create an sxpr by parsing a string. - str string + s string returns sxpr """ - io = StringIO(str) + if s == '': + return [] + + io = StringIO(s) vals = parse(io) if vals is []: return None @@ -710,13 +713,13 @@ def from_string(str): return vals[0] -def all_from_string(str): +def all_from_string(s): """Create an sxpr list by parsing a string. - str string + s string returns sxpr list """ - io = StringIO(str) + io = StringIO(s) vals = parse(io) return vals -- 2.30.2